package com.sx.zongzhi.presenter;

import com.sx.zongzhi.MyApplication;
import com.sx.zongzhi.bean.KeyTradesBean;
import com.sx.zongzhi.bean.KeyTradesSearchBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IKeyTradesView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2017/11/30.
 *获取重点行业
 */
public class KeyTradesPest {

    private IKeyTradesView keyTradesView;

    public KeyTradesPest(IKeyTradesView keyTradesView) {
        this.keyTradesView=keyTradesView;
    }


    /**
     *
     * @param orgId 当前操作网格id
     * @param searchBean 重点行业查询bean
     * @param page
     * @param rows
     */
    public void getKeyTradesList(String orgId, KeyTradesSearchBean searchBean, int page, int rows){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("orgId", orgId);
        if (searchBean!=null){
            map.put("keyIndustry.name",searchBean.getKeyAreaName());
            map.put("keyIndustry.address", searchBean.getAddress());
            map.put("keyIndustry.industryType.id", searchBean.getTradesType());
            map.put("keyIndustry.quality.id", searchBean.getTradesQulity());
            map.put("keyIndustry.licenseNumber", searchBean.getBusinessNum());
            map.put("keyIndustry.nativePoliceStation", searchBean.getPolice());
            map.put("keyIndustry.legalRepresentative", searchBean.getHeader());
            map.put("keyIndustry.legalPersonPhone", searchBean.getTelephone());
            map.put("keyIndustry.mobileNumber", searchBean.getPhone());
            map.put("keyIndustry.telephone", searchBean.getCompanyTel());
            map.put("keyIndustry.faxTelephone", searchBean.getCompanyFix());
            map.put("keyIndustry.minEmployeesNumber", searchBean.getEmployeeSmall());
            map.put("keyIndustry.maxEmployeesNumber", searchBean.getEmployeeBig());
            map.put("keyIndustry.minRegisteredCapital", searchBean.getMoneySmall());
            map.put("keyIndustry.maxRegisteredCapital", searchBean.getMoneyBig());
        }
        map.put("page", page);
        map.put("rows", rows);
        new ApiManager().getKeyTradesList(map, new BaseCallBack<BaseResult<KeyTradesBean>>() {
            @Override
            public void onSuccess(BaseResult<KeyTradesBean> response) {
                keyTradesView.getKeyTradesList(response.getData());
            }
            @Override
            public void onFailures(String message) {
                keyTradesView.showError(message);
            }
        });
    }

}
